import numpy as np
from mindspore import Tensor


# x = Tensor(np.array([1, 2], dtype=np.float32))

# https://numpy.org/doc/stable/reference/generated/numpy.testing.assert_allclose.html
# x = np.array([[[1e-5, 1e-3, 1e-4, 3e-1], [1e-5, 1e-3, 1e-4, 3e-1], [1e-5, 1e-3, 1e-4, 3e-1]],
#               [[1e-5, 1e-3, 1e-4, 3e-1], [1e-5, 1e-3, 1e-4, 3e-1], [1e-5, 1e-3, 1e-4, 3e-1]]])
# # y = np.arccos(x)
# y = np.array([[[1e-3, 1e-3, 1e-4, 4e-1], [1e-3, 1e-3, 1e-4, 4e-1], [1e-3, 1e-3, 1e-4, 4e-1]],
#               [[1e-3, 1e-3, 1e-4, 4e-1], [1e-3, 1e-3, 1e-4, 4e-1], [1e-3, 1e-3, 1e-4, 4e-1]]])

def load_npy(x_path, y_path):
    x = np.load(x_path)
    y = np.load(y_path)
    return x, y


def ms_save_tensor():
    x1, y1 = load_npy("nps/x.npy", "nps/y.npy")
    ms_x = Tensor(x1)
    ms_y = Tensor(y1)
    np.save("nps/ms_x.npy", ms_x.asnumpy())
    np.save("nps/ms_y.npy", ms_y.asnumpy())


ms_save_tensor()
